home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.4)
-
- import re
- import unittest
- import warnings
- from test import test_support
-
- class SyntaxTestCase(unittest.TestCase):
-
- def _check_error(self, code, errtext, filename = '<testcase>', mode = 'exec'):
- '''Check that compiling code raises SyntaxError with errtext.
-
- errtest is a regular expression that must be present in the
- test of the exception raised.
- '''
-
- try:
- compile(code, filename, mode)
- except SyntaxError:
- err = None
- mo = re.search(errtext, str(err))
- if mo is None:
- self.fail("SyntaxError did not contain '%r'" % (errtext,))
-
- except:
- mo is None
-
- self.fail('compile() did not raise SyntaxError')
-
-
- def test_assign_call(self):
- self._check_error('f() = 1', 'assign')
-
-
- def test_assign_del(self):
- self._check_error('del f()', 'delete')
-
-
- def test_global_err_then_warn(self):
- source = re.sub('(?m)^ *:', '', ' :def error(a):\n : global a # SyntaxError\n :def warning():\n : b = 1\n : global b # SyntaxWarning\n :')
- warnings.filterwarnings(action = 'ignore', category = SyntaxWarning)
- self._check_error(source, 'global')
- warnings.filters.pop(0)
-
-
-
- def test_main():
- test_support.run_unittest(SyntaxTestCase)
-
- if __name__ == '__main__':
- test_main()
-
-